package cn.biplam.front.component.view.mdManage;

import cn.biplam.common.bean.md.MdTableCol;
import cn.biplam.common.paramters.ModelType.Model_Type;
import cn.biplam.common.tools.TOOLS;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.template.base.Text;

/**
 * 业务模型字段描述组件 用于获取业务模型字段描述 页面格式为：字段物理名(字段逻辑名)
 * @author XiaoRuxing Aug 15, 20099:57:33 AM
 * @version 1.0
 */
public class ModelFieldDesc {

	private Model_Type modelType;
	private String fieldID;
	private UserInfo mUser;

	/**
	 * 创建模型表描述界面
	 * @param mUser     用户信息
	 * @param modelType 模型类型
	 * @param fieldID   字段ID
	 */
	public ModelFieldDesc(UserInfo mUser,Model_Type modelType,String fieldID){
		this.modelType = modelType;
		this.fieldID = fieldID;
		this.mUser = mUser;
	}

	/**
	 * 获取模型表字段描述组件
	 * @return
	 * @throws ErrorMessage
	 */
	public HtmlWindow get() throws ErrorMessage{
		MdTableCol tableCol = MdTableCol.getNewInstance(mUser,fieldID,this.modelType.toString());
		String fieldName = tableCol.getName();
		String fieldDesc = null;
		if(!TOOLS.StringIsEmpty(fieldName)){
			fieldDesc = fieldName+"("+
			TOOLS.stringNullToEmpty(tableCol.getCnName())+")";
		}
		HtmlWindow field = new Text(fieldDesc).get();
		return field;
	}
}
